﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExpertMIS.Entities;
using ExpertMIS.Brokers;

namespace ExpertMIS.Workships
{
    public partial class AskForMePosts : ExpertMIS.Codes.PostPage
    {
        private string GetCurrentExpertOID()
        {
            ADMUserEntity user = CurrentUser as ADMUserEntity;

            if (user.IsExpert == true)
            {
                ExpertBroker expertBroker = new ExpertBroker();
                ExpertEntity expert = expertBroker.GetExpertEntityByUserID(user.OID) as ExpertEntity;

                return expert.OID;
            }

            return string.Empty;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ucSearchResult1.SearchToExpert(GetCurrentExpertOID(), null);
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ucSearchResult1.SearchToExpert(GetCurrentExpertOID(), q.Text);
        }
    }
}
